实验现象:
打开tool-->Netlist viewer-->RTL viewer可观察各个逻辑连接
核心代码:
//--------------------module_logic_gates---------------------//
module logic_gates(
input clk_25m,
output c,
output d,
output e,
output f,
output g,
output h,
output i,
output j,
output k,
output l
);
//--------------------logic_gates_ctrl----------------------//
reg [:]b; //产生输入信号b
always@(posedge clk_25m)
if(b == 'd1000)
b <= 'd0;
else b <= b + 'd1; reg [:]a; //产生输入信号a
always@(posedge clk_25m)
if(a == 'd500)
a <= 'd0;
else a <= a + 'd1; assign c = a[] && b[]; //逻辑与
assign d = a[] || b[]; //逻辑或
assign e = !a[]; //逻辑非 assign f = a[] & b[]; //按位与
assign g = a[] | b[]; //按位或
assign h = ~a[]; //按位非
assign i = a[] &~ b[]; //按位与非
assign j = a[] |~ b[]; //按位或非
assign k = a[] ^ b[]; //按位异或
assign l = a[] ~^ b[]; //按位同或 //--------------------endmodule---------------------------//
endmodule
源代码下载链接:
链接:http://pan.baidu.com/s/1mi5fZy4 密码:mqcz
iCore4链接: