2014年5月24日 星期六

用Verilog 描述七段顯示器


//===============================
module hex_7seg (hex,seg_out);
  input [3:0] hex;
  output reg [6:0] seg_out;

always@ (hex)

begin
  case (hex)
    //                     gfe_dcba 7-segment
    4'b0000 : seg_out  = 7'b100_0000;
    4'b0001 : seg_out  = 7'b111_1001;
    4'b0010 : seg_out  = 7'b010_0100;
    4'b0011 : seg_out  = 7'b011_0000;
    4'b0100 : seg_out  = 7'b001_1001;
    4'b0101 : seg_out  = 7'b001_0010;
    4'b0110 : seg_out  = 7'b000_0010;
    4'b0111 : seg_out  = 7'b111_1000;
    4'b1000 : seg_out  = 7'b000_0000;
    4'b1001 : seg_out  = 7'b001_0000;
    4'b1010 : seg_out  = 7'b000_1000;
    4'b1011 : seg_out  = 7'b000_0011;
    4'b1100 : seg_out  = 7'b100_0110;
    4'b1101 : seg_out  = 7'b010_0001;
    4'b1110 : seg_out  = 7'b000_0110;
    default : seg_out  = 7'b000_1110;
    endcase
  end
endmodule

沒有留言:

張貼留言

Modbus FC=1 (Coils read) & FC=15 (Coils Write)

Modbus FC=1  (Coils read)  & FC=15 (Coils Write)   「從 Modbus 設備讀取多個線圈(Coils)狀態,並立刻將這些狀態原封不動地轉寫到另一個記憶體位址(起始位址 16)」 。 整個流程使用了知名套件 node-red...