java 调用msax_jchdl - GSL实例 - Mux4(使用Mux)

原理图

dffbd85458304c11feef4df4190b6292.png

参考链接

1.创建Mux4.java, 并生成构造方法和logic()方法

9e9e92dff4935225a225529a8b42d9a4.png

2. 根据逻辑原理图,添加输入输出线

06a84e850f478d4cf2e0610a6d13852f.png

3. 在构造方法中搜集输入输出线并调用construct()方法

597309c401dbe066a12985f845eb0298.png

4. 在logic()方法中创建子节点并连线

8392e3aa6e920e2c951a0e0b367d9f15.png

5. 创建inst静态方法方便后续使用

5fe8f0a89250f2591de55c2998b48812.png

6. 创建main方法执行验证

c745a33a6abee9178700089bc242d3ce.png

运行结果为:

93478d347448fc0d1f8855368ea0ea30.png

四种组合逐个选择i0~i3中的值。

7. 生成Verilog

2d520e0ab94bcf8cbb98843e5f784340.png

执行结果如下:

25f5b109170a8c6c09b15c393b95190d.png

import org.jchdl.model.gsl.core.datatype.net.Wire;

import org.jchdl.model.gsl.core.meta.Node;

import org.jchdl.model.gsl.core.meta.PropagateManager;

import org.jchdl.model.gsl.core.value.Value;

import org.jchdl.model.gsl.operator.conditional.Mux;

public class Mux4 extends Node {

private Wire i0;

private Wire i1;

private Wire i2;

private Wire i3;

private Wire s1;

private Wire s0;

private Wire out;

private Wire o0 = new Wire();

private Wire o1 = new Wire();

public Mux4(Wire out, Wire i0, Wire i1, Wire i2, Wire i3, Wire s1, Wire s0) {

in(Wire.array(i0, i1, i2, i3, s1, s0));

out(out);

construct();

}

@Override

public void logic() {

i0 = new Wire(in(0));

i1 = new Wire(in(1));

i2 = new Wire(in(2));

i3 = new Wire(in(3));

s1 = new Wire(in(4));

s0 = new Wire(in(5));

out = new Wire(out(0));

Mux.inst(o0, i0, i1, s0);

Mux.inst(o1, i2, i3, s0);

Mux.inst(out, o0, o1, s1);

}

public static Mux4 inst(Wire out, Wire i0, Wire i1, Wire i2, Wire i3, Wire s1, Wire s0) {

return new Mux4(out, i0, i1, i2, i3, s1, s0);

}

public static void main(String[] args) {

Wire i0 = new Wire(Value.V0);

Wire i1 = new Wire(Value.V1);

Wire i2 = new Wire(Value.V0);

Wire i3 = new Wire(Value.V1);

Wire s1 = new Wire(Value.V0);

Wire s0 = new Wire(Value.V0);

Wire out = new Wire();

Mux4 mux4 = Mux4.inst(out, i0, i1, i2, i3, s1, s0);

PropagateManager.propagateParallel(i0, i1, i2, i3, s1, s0);

System.out.println("out: " + out.getValue().toString());

s1.assign(Value.V0);

s0.assign(Value.V1);

PropagateManager.propagateParallel(s1, s0);

System.out.println("out: " + out.getValue().toString());

s1.assign(Value.V1);

s0.assign(Value.V0);

PropagateManager.propagateParallel(s1, s0);

System.out.println("out: " + out.getValue().toString());

s1.assign(Value.V1);

s0.assign(Value.V1);

PropagateManager.propagateParallel(s1, s0);

System.out.println("out: " + out.getValue().toString());

mux4.toVerilog();

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值