1 /* ****************************************************************************
\r
2 -- Source file: mesa_id.v
\r
3 -- Date: October 2015
\r
5 -- Description: Simple state machine the reports chip ID over mesa-bus on
\r
6 -- request and muxes in the normal Ro byte path when idle.
\r
7 -- Language: Verilog-2001
\r
8 -- Simulation: Mentor-Modelsim
\r
9 -- Synthesis: Lattice
\r
10 -- License: This project is licensed with the CERN Open Hardware Licence
\r
11 -- v1.2. You may redistribute and modify this project under the
\r
12 -- terms of the CERN OHL v.1.2. (http://ohwr.org/cernohl).
\r
13 -- This project is distributed WITHOUT ANY EXPRESS OR IMPLIED
\r
14 -- WARRANTY, INCLUDING OF MERCHANTABILITY, SATISFACTORY QUALITY
\r
15 -- AND FITNESS FOR A PARTICULAR PURPOSE. Please see the CERN OHL
\r
16 -- v.1.2 for applicable Conditions.
\r
18 -- Revision History:
\r
19 -- Ver# When Who What
\r
20 -- ---- -------- -------- ---------------------------------------------------
\r
21 -- 0.1 10.04.15 khubbard Creation
\r
22 -- ***************************************************************************/
\r
23 `default_nettype none // Strictly enforce all nets to be declared
\r
29 input wire report_id,
\r
30 input wire [31:0] id_mfr,
\r
31 input wire [31:0] id_dev,
\r
32 input wire [31:0] id_snum,
\r
33 input wire [7:0] mesa_core_ro_byte_d,
\r
34 input wire mesa_core_ro_byte_en,
\r
35 input wire mesa_core_ro_done,
\r
36 input wire mesa_ro_busy,
\r
37 output reg [7:0] mesa_ro_byte_d,
\r
38 output reg mesa_ro_byte_en,
\r
39 output reg mesa_ro_done
\r
44 reg [4:0] report_cnt;
\r
45 reg mesa_ro_busy_p1;
\r
46 wire [31:0] time_stamp_d;
\r
49 //-----------------------------------------------------------------------------
\r
50 // Ro binary bytes are converted to 2 ASCII nibble chars for MesaBus Ro
\r
51 // This is also a report_id FSM that muxes into the ro byte path on request.
\r
52 //-----------------------------------------------------------------------------
\r
53 always @ ( posedge clk ) begin : proc_mesa_ro_byte
\r
54 report_id_p1 <= report_id;
\r
55 mesa_ro_byte_d[7:0] <= mesa_core_ro_byte_d[7:0];
\r
56 mesa_ro_byte_en <= mesa_core_ro_byte_en;
\r
57 mesa_ro_done <= mesa_core_ro_done;
\r
58 mesa_ro_busy_p1 <= mesa_ro_busy;
\r
60 // When report_id asserts ( SubSlot 0xFA command ) shift out
\r
61 // a unique 32bit ID of 16 bit Manufacture and 16bit Device
\r
62 if ( report_id == 1 ) begin
\r
63 report_jk <= 1;// Start FSM
\r
67 // State Machine for sending out device id when requested
\r
68 mesa_ro_busy_p1 <= mesa_ro_busy;
\r
69 if ( report_jk == 1 ) begin
\r
70 mesa_ro_byte_en <= 0;
\r
73 if ( report_id_p1==1 || ( mesa_ro_busy_p1==1 && mesa_ro_busy==0 )) begin
\r
74 report_cnt <= report_cnt[4:0] + 1;
\r
75 mesa_ro_byte_en <= 1;
\r
76 if ( report_cnt == 5'd0 ) begin
\r
77 mesa_ro_byte_d[7:0] <= 8'hF0;// Header : Preamble
\r
78 end else if ( report_cnt == 5'd1 ) begin
\r
79 mesa_ro_byte_d[7:0] <= 8'hFE;// Header : Ro Slot is 0xFE
\r
80 end else if ( report_cnt == 5'd2 ) begin
\r
81 mesa_ro_byte_d[7:0] <= 8'h00;// Header : Ro Subslot is 0x00
\r
82 end else if ( report_cnt == 5'd3 ) begin
\r
83 mesa_ro_byte_d[7:0] <= 8'h10;// Header : 16 Bytes in Payload
\r
85 end else if ( report_cnt == 5'd4 ) begin
\r
86 mesa_ro_byte_d[7:0] <= id_mfr[31:24];
\r
87 end else if ( report_cnt == 5'd5 ) begin
\r
88 mesa_ro_byte_d[7:0] <= id_mfr[23:16];
\r
89 end else if ( report_cnt == 5'd6 ) begin
\r
90 mesa_ro_byte_d[7:0] <= id_mfr[15:8];
\r
91 end else if ( report_cnt == 5'd7 ) begin
\r
92 mesa_ro_byte_d[7:0] <= id_mfr[7:0];
\r
94 end else if ( report_cnt == 5'd8 ) begin
\r
95 mesa_ro_byte_d[7:0] <= id_dev[31:24];
\r
96 end else if ( report_cnt == 5'd9 ) begin
\r
97 mesa_ro_byte_d[7:0] <= id_dev[23:16];
\r
98 end else if ( report_cnt == 5'd10) begin
\r
99 mesa_ro_byte_d[7:0] <= id_dev[15:8];
\r
100 end else if ( report_cnt == 5'd11) begin
\r
101 mesa_ro_byte_d[7:0] <= id_dev[7:0];
\r
103 end else if ( report_cnt == 5'd12) begin
\r
104 mesa_ro_byte_d[7:0] <= id_snum[31:24];
\r
105 end else if ( report_cnt == 5'd13) begin
\r
106 mesa_ro_byte_d[7:0] <= id_snum[23:16];
\r
107 end else if ( report_cnt == 5'd14) begin
\r
108 mesa_ro_byte_d[7:0] <= id_snum[15:8];
\r
109 end else if ( report_cnt == 5'd15) begin
\r
110 mesa_ro_byte_d[7:0] <= id_snum[7:0];
\r
112 end else if ( report_cnt == 5'd16) begin
\r
113 mesa_ro_byte_d[7:0] <= time_stamp_d[31:24];
\r
114 end else if ( report_cnt == 5'd17) begin
\r
115 mesa_ro_byte_d[7:0] <= time_stamp_d[23:16];
\r
116 end else if ( report_cnt == 5'd18) begin
\r
117 mesa_ro_byte_d[7:0] <= time_stamp_d[15:8];
\r
118 end else if ( report_cnt == 5'd19) begin
\r
119 mesa_ro_byte_d[7:0] <= time_stamp_d[7:0];
\r
120 mesa_ro_done <= 1;// Send LF
\r
121 report_jk <= 0;// All Done - stop FSM
\r
123 mesa_ro_byte_d[7:0] <= 8'h00;// 0x00 = NULL
\r
126 end // if ( report_jk == 1 ) begin
\r
128 end // proc_mesa_ro_byte
\r
130 //-----------------------------------------------------------------------------
\r
131 // 32bit UNIX TimeStamp of when the design was synthesized
\r
132 //-----------------------------------------------------------------------------
\r
133 time_stamp u_time_stamp
\r
135 .time_dout ( time_stamp_d[31:0] )
\r
139 endmodule // mesa_id.v
\r