DE2-115 開發 以或閘OR Gate 為例(Verilog)
gate-level modeling & Data flow modeling
記得要import pin assignment [DE2_115_pin_assignments.csv]
//7432 OR Gate
module gate_7432_or(SW,LEDR );
input [17:0] SW;
output [17:0] LEDR;
or_gate(SW[17:0],LEDR[17:0]);
endmodule
//======================
//-- or_gate.v
//-- Component has an input (Din) and an output (Dout)
module or_gate( Din, Dout );
input [17:0]Din;
output [17:0]Dout;
//-- Both the input and the output are "wires"
wire [17:0]Din;
wire [17:0]Dout;
//gate-level modeling
or(Dout[0], Din[0], Din[1]);
or (Dout[2], Din[2], Din[3]);
// Data flow modeling
assign Dout[4]= (Din[4] | Din[5]);
assign Dout[6]= (Din[6] | Din[7]);
assign Dout[8]= (Din[8] | Din[9]);
assign Dout[10]= (Din[10] | Din[11]);
assign Dout[12]= (Din[12] | Din[13]);
assign Dout[14]= (Din[14] | Din[15]);
assign Dout[16]= (Din[16] | Din[17]);
//behavioral modeling
endmodule
沒有留言:
張貼留言