2012年10月8日 星期一
P4-17 2bit比較器配合DE2-70修改後程式
只要import DE2-70 pin assignments 即可執行
//=======================================
module comp4bit (SW, LEDR, LEDG);
input [17:0] SW; // toggle switches
output [17:0] LEDR; // red LEDs
output [7:0] LEDG; // green LEDs
wire eq2,gt2,lt2; //comout[2]:great than, comout[1]:equal
//comout[0]:less than
wire [1:0] a, b; //input data
//mapping to hardware
assign LEDR = SW;
assign a = SW[1:0];
assign b = SW[9:8];
wire el,gl,ll ; //LSB output equal->el , great than->gl , less than->ll
wire eh,gh,lh ; //MSB output equal , great than , less than
wire gla,lla ;
and (gla,gl,eh);
and (lla,ll,eh);
//Instantiated by name
comp1_g UUT1(.eq(el),.gt(gl),.lt(ll),.a(a[0]),.b(b[0]));
comp1_g UUT2(.eq(eh),.gt(gh),.lt(lh),.a(a[1]),.b(b[1]));
//and or gates are instantabtiated
and (eq2,el,eh); //equal
or(gt2,gla,gh); //great than
or(lt2,lla,lh); //less than
assign LEDG[1]=eq2;
assign LEDG[0]=lt2;
assign LEDG[2]=gt2;
endmodule
//===========================================
// 1-bit comparater gate-level
//filename : comp1_g.v
module comp1_g( a, b,eq,gt,lt); //eq =EQUAL gt:Great Than lt :Less than
input a,b;
output eq,gt,lt;
wire an,bn,a0b0,a1b1 ; //internal signal declare
not(an,a);
not(bn,b);
and(a1b1,a,b);
nor(a0b0,a,b);
or(eq,a0b0,a1b1); //eq
and(gt,a,bn); //gt
and(lt,an,b); //lt
endmodule
訂閱:
張貼留言 (Atom)
MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ
MQTT WS HMI 與 Wokwi ESP32 連線的資訊透過HiveMQ https://console.hivemq.cloud/clusters 當您進入 HiveMQ Cloud Console 的 Clusters 頁面時,您的目標是取得能讓 MQTT W...


沒有留言:
張貼留言