首页 技术 正文
技术 2022年11月16日
0 收藏 505 点赞 3,942 浏览 1971 个字

https://mp.weixin.qq.com/s/GrYJ4KXEFRoLLmLnAGoMSA

原理图

jchdl – GSL实例 – Mux4(使用Mux)

参考链接

https://github.com/wjcdx/jchdl/blob/master/src/org/jchdl/model/gsl/example/Mux4.java

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

jchdl – GSL实例 – Mux4(使用Mux)

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

jchdl – GSL实例 – Mux4(使用Mux)

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

jchdl – GSL实例 – Mux4(使用Mux)

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

jchdl – GSL实例 – Mux4(使用Mux)

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

jchdl – GSL实例 – Mux4(使用Mux)

6. 创建main方法执行验证

jchdl – GSL实例 – Mux4(使用Mux)

运行结果为:

jchdl – GSL实例 – Mux4(使用Mux)

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

7. 生成Verilog

jchdl – GSL实例 – Mux4(使用Mux)

执行结果如下:

jchdl – GSL实例 – Mux4(使用Mux)

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();

}

}

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,086
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,561
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,410
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,183
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,820
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,903