jchdl - GSL实例 - Mux4(使用Mux)
https://mp.weixin.qq.com/s/GrYJ4KXEFRoLLmLnAGoMSA
原理图
参考链接
https://github.com/wjcdx/jchdl/blob/master/src/org/jchdl/model/gsl/example/Mux4.java
1.创建Mux4.java, 并生成构造方法和logic()方法
2. 根据逻辑原理图,添加输入输出线
3. 在构造方法中搜集输入输出线并调用construct()方法
4. 在logic()方法中创建子节点并连线
5. 创建inst静态方法方便后续使用
6. 创建main方法执行验证
运行结果为:
四种组合逐个选择i0~i3中的值。
7. 生成Verilog
执行结果如下:
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();
}
}
jchdl - GSL实例 - Mux4(使用Mux)的更多相关文章
- jchdl - GSL实例 - Mux4(使用WireVec简化输入线声明)
https://mp.weixin.qq.com/s/yJx_dV6ScUStJtPWVuD38w 原理图 参考链接 https://github.com/wjcdx/jchdl/blob/ma ...
- jchdl - GSL实例 - Mux4
https://mp.weixin.qq.com/s/hh0eExVFC6cxzpvNI1cA9A 使用门实现四选一选择器. 原理图 参考链接 https://github.com/wjcdx/ ...
- jchdl - GSL实例 - Add
https://mp.weixin.qq.com/s/6xcYYdYZTBPTf25xFluzBQ 使用FullAdder级联实现加法器 参考链接: https://github.com/wj ...
- jchdl - GSL实例 - DFlipFlop(D触发器)
https://mp.weixin.qq.com/s/7N3avTxTd2ZUnAcKg4w3Ig D触发器对边沿敏感,只有当相应的边沿出现时,才会触发D的值传播到输出Q. 引自:htt ...
- jchdl - GSL实例 - Div
因为对除法研究不深,这里略去不表. 有兴趣可以参考链接: https://github.com/wjcdx/jchdl/blob/master/src/org/jchdl/model/gsl/op ...
- jchdl - GSL实例 - MulC2(有符号数的乘法)
这里的实现,先把符号位取出来,使用两个正数相乘,然后在把符号加到乘积上. 参考链接 https://github.com/wjcdx/jchdl/blob/master/src/org/jch ...
- jchdl - GSL实例 - Mul(无符号数的乘法)
这里实现最原始的阵列乘法,逐位相乘然后加到一起. 参考链接 https://github.com/wjcdx/jchdl/blob/edcc3e098d4f1cb21677e86e87a114 ...
- jchdl - GSL实例 - LogicalLeft
https://mp.weixin.qq.com/s/WNm4bLWzZ0oWHWa7HQ6Y6w 逻辑左移,继承自Shifter类.只需要实现shift方法即可. 参考链接 https:// ...
- jchdl - GSL实例 - Shifter
https://mp.weixin.qq.com/s/ngQji-xi4FCCbL_2ihUi_A Shifter是移位节点的父类,定义了输入输出线,但是没有定义具体的移位方式,这个留给子类去实现 ...
随机推荐
- Spring Cloud 系列之 Bus 消息总线
什么是消息总线 消息代理中间件构建一个共用的消息主题让所有微服务实例订阅,当该消息主题产生消息时会被所有微服务实例监听和消费. 消息代理又是什么?消息代理是一个消息验证.传输.路由的架构模式,主要用来 ...
- python 一个模块找不到的错误:ModuleNotFoundError
阿刁是一个自动化测试用例,从一出生他就被赋予终生使命,去测试一个叫登录的过程是否合理.他一直就被关在一个小黑屋里面,从来也没有出去过,小黑屋里还被关着其他的同胞,他们身上都捆着两个小袋子. 小黑屋里很 ...
- thread模块—Python多线程编程
Thread 模块 *注:在实际使用过程中不建议使用 thread 进行多线程编程,本文档只为学习(或熟悉)多线程使用. Thread 模块除了派生线程外,还提供了基本的同步数据结构,称为锁对象(lo ...
- Mysql 常用函数(8)- concat 函数
Mysql常用函数的汇总,可看下面系列文章 https://www.cnblogs.com/poloyy/category/1765164.html concat 的作用 连接多个字符串 concat ...
- 8、HTTPS证书Actions无法导出问题
前言 在点Actions时候出现Export Failed:The root certificate could not be located.最近有很多小伙伴在fiddler导出证书的时候,遇到无法 ...
- 搞懂js中小数运算精度问题原因及解决办法
js小数运算会出现精度问题 js number类型 JS 数字类型只有number类型,number类型相当于其他强类型语言中的double类型(双精度浮点型),不区分浮点型和整数型. number类 ...
- 什么是virtual string tree?
Virtual stringtree(以后简称VST)是一个提供源码的免费的第三方插件,支持DELPHI和C++builder,可在http://www.soft-gems.net/下载到最新的版本. ...
- git init 后关联github仓库是发生错误:
: failed to push some refs to 'git@github.com:AlanKnightly/reactC.git'hint: Updates were rejected be ...
- python中copy与deepcopy的区别
目录 区别 python代码举例 区别 高级语言中变量是对内存及其地址的抽象 copy.copy(object), 拷贝的是内嵌套结构的地址引用,当前到结构发生变化的时候,浅拷贝也相应的改变. cop ...
- MySQL的列约束
1.列约束 (1)主键约束——PRIMARY KEY (2)非空约束——NOT NULL 声明了非空约束的列上,不允许使用NULL (3)唯一约束——UNIQUE 声明了唯一约束的列上不能插入重复的值 ...