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)的更多相关文章

  1. jchdl - GSL实例 - Mux4(使用WireVec简化输入线声明)

    https://mp.weixin.qq.com/s/yJx_dV6ScUStJtPWVuD38w 原理图 ​​ 参考链接 https://github.com/wjcdx/jchdl/blob/ma ...

  2. jchdl - GSL实例 - Mux4

    https://mp.weixin.qq.com/s/hh0eExVFC6cxzpvNI1cA9A 使用门实现四选一选择器. 原理图 ​​ 参考链接 https://github.com/wjcdx/ ...

  3. jchdl - GSL实例 - Add

    https://mp.weixin.qq.com/s/6xcYYdYZTBPTf25xFluzBQ   使用FullAdder级联实现加法器   参考链接: https://github.com/wj ...

  4. jchdl - GSL实例 - DFlipFlop(D触发器)

    https://mp.weixin.qq.com/s/7N3avTxTd2ZUnAcKg4w3Ig   D触发器对边沿敏感,只有当相应的边沿出现时,才会触发D的值传播到输出Q.   ​​ 引自:htt ...

  5. jchdl - GSL实例 - Div

    因为对除法研究不深,这里略去不表.   有兴趣可以参考链接: https://github.com/wjcdx/jchdl/blob/master/src/org/jchdl/model/gsl/op ...

  6. jchdl - GSL实例 - MulC2(有符号数的乘法)

      这里的实现,先把符号位取出来,使用两个正数相乘,然后在把符号加到乘积上.   参考链接 https://github.com/wjcdx/jchdl/blob/master/src/org/jch ...

  7. jchdl - GSL实例 - Mul(无符号数的乘法)

      这里实现最原始的阵列乘法,逐位相乘然后加到一起.   参考链接 https://github.com/wjcdx/jchdl/blob/edcc3e098d4f1cb21677e86e87a114 ...

  8. jchdl - GSL实例 - LogicalLeft

    https://mp.weixin.qq.com/s/WNm4bLWzZ0oWHWa7HQ6Y6w   逻辑左移,继承自Shifter类.只需要实现shift方法即可.   参考链接 https:// ...

  9. jchdl - GSL实例 - Shifter

    https://mp.weixin.qq.com/s/ngQji-xi4FCCbL_2ihUi_A   Shifter是移位节点的父类,定义了输入输出线,但是没有定义具体的移位方式,这个留给子类去实现 ...

随机推荐

  1. Struts Scan工具的使用

    前言 最近看了关于Struts2漏洞,参考文章 https://www.freebuf.com/vuls/168609.html,这篇文章里对Struts2的漏洞及原理进行了详细的讲解.自己也从网上找 ...

  2. Blazor入门:ASP.NET Core Razor 组件

    目录 关于组件 组件类 静态资产 路由与路由参数 组件参数 请勿创建会写入其自己的组参数属性的组件 子内容 属性展开 任意参数 捕获对组件的引用 在外部调用组件方法以更新状态 使用 @ 键控制是否保留 ...

  3. iOS中的几种锁的总结,三种开启多线程的方式(GCD、NSOperation、NSThread)

    学习内容 欢迎关注我的iOS学习总结--每天学一点iOS:https://github.com/practiceqian/one-day-one-iOS-summary OC中的几种锁 为什么要引入锁 ...

  4. [LA7139 Rotation(2014 shanghai onsite)]二维树状数组

    题意:有一个n*m的矩形,一辆车从左上角出发,沿一条路径走,路径是由矩形上每个单元格的边构成的,最后回到左上角,求车子在每个格子转过圈数的平方和. 思路:假设需要记录每个格子转的顺时针的圈数(为负表示 ...

  5. 基于Memcached的Nginx服务器集群session共享

    原料:jdk1.8,tomcat7,nginx1.16,memcached-1.2.6,Mem-Tomcat需要的jar包,基于windows7.所有的点击以下链接可下载 链接:https://pan ...

  6. 黑马程序员_毕向东_Java基础视频教程——算术运算符小点(随笔)

    算术运算符小点 ​ 取模 class Test{ public static void main(String[] args){ System.out.println( 1 % -5); System ...

  7. Failed to start mongod.service: Unit not found

    其实自己用惯的是MYSQL,然后项目最后一步完善数据读写的部分,本来打算用mysql的,然而在centOS系统上发现安装总是出问题,后来查找一下资料,发现centOS系统上一般用的是Mariadb,这 ...

  8. Django视图函数之request请求与response响应对象

    官方文档: https://docs.djangoproject.com/en/1.11/ref/request-response/ 视图中的request请求对象: 当请求页面时,Django创建一 ...

  9. MYSQL 中binlog 参数的记录

    http://dev.mysql.com/doc/refman/5.7/en/replication-options-binary-log.html binlog_cache_size Command ...

  10. 导出word excel 方法

    ---导出excel public static void DataTableToExcelXjd(DataTable dt, string Title, string TmpColsName) { ...