|
| 1 | +// Copyright (c) 2023, Andrew Kay |
| 2 | +// |
| 3 | +// Permission to use, copy, modify, and/or distribute this software for any |
| 4 | +// purpose with or without fee is hereby granted, provided that the above |
| 5 | +// copyright notice and this permission notice appear in all copies. |
| 6 | +// |
| 7 | +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 8 | +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 9 | +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 10 | +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 11 | +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 12 | +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 13 | +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 14 | + |
| 15 | +`default_nettype none |
| 16 | + |
| 17 | +module wrap_tester_out ( |
| 18 | + input wire clk, |
| 19 | + input wire enable, |
| 20 | + |
| 21 | + input wire [19:0] driver, |
| 22 | + output reg [19:0] receiver, |
| 23 | + |
| 24 | + // Parallel Channel "B"... |
| 25 | + output reg [7:0] b_bus_in, |
| 26 | + output reg b_bus_in_parity, |
| 27 | + input wire [7:0] b_bus_out, |
| 28 | + input wire b_bus_out_parity, |
| 29 | + output reg b_mark_0_in, |
| 30 | + input wire b_mark_0_out, |
| 31 | + |
| 32 | + input wire b_operational_out, |
| 33 | + output reg b_request_in, |
| 34 | + input wire b_hold_out, |
| 35 | + input wire b_select_out, |
| 36 | + output reg b_select_in, |
| 37 | + input wire b_address_out, |
| 38 | + output reg b_operational_in, |
| 39 | + output reg b_address_in, |
| 40 | + input wire b_command_out, |
| 41 | + output reg b_status_in, |
| 42 | + output reg b_service_in, |
| 43 | + input wire b_service_out, |
| 44 | + input wire b_suppress_out, |
| 45 | + output reg b_data_in, |
| 46 | + input wire b_data_out, |
| 47 | + output reg b_disconnect_in, |
| 48 | + output reg b_metering_in, |
| 49 | + input wire b_metering_out, |
| 50 | + input wire b_clock_out, |
| 51 | + |
| 52 | + // Parallel Channel "A"... |
| 53 | + input wire [7:0] a_bus_in, |
| 54 | + input wire a_bus_in_parity, |
| 55 | + output reg [7:0] a_bus_out, |
| 56 | + output reg a_bus_out_parity, |
| 57 | + input wire a_mark_0_in, |
| 58 | + output reg a_mark_0_out, |
| 59 | + |
| 60 | + output reg a_operational_out, |
| 61 | + input wire a_request_in, |
| 62 | + output reg a_hold_out, |
| 63 | + output reg a_select_out, |
| 64 | + input wire a_select_in, |
| 65 | + output reg a_address_out, |
| 66 | + input wire a_operational_in, |
| 67 | + input wire a_address_in, |
| 68 | + output reg a_command_out, |
| 69 | + input wire a_status_in, |
| 70 | + input wire a_service_in, |
| 71 | + output reg a_service_out, |
| 72 | + output reg a_suppress_out, |
| 73 | + input wire a_data_in, |
| 74 | + output reg a_data_out, |
| 75 | + input wire a_disconnect_in, |
| 76 | + input wire a_metering_in, |
| 77 | + output reg a_metering_out, |
| 78 | + output reg a_clock_out |
| 79 | +); |
| 80 | + always @(posedge clk) |
| 81 | + begin |
| 82 | + if (enable) |
| 83 | + begin |
| 84 | + b_bus_in <= 8'b0; |
| 85 | + b_bus_in_parity <= 1'b0; |
| 86 | + b_mark_0_in <= 1'b0; |
| 87 | + b_request_in <= 1'b0; |
| 88 | + b_select_in <= b_select_out; |
| 89 | + b_operational_in <= 1'b0; |
| 90 | + b_address_in <= 1'b0; |
| 91 | + b_status_in <= 1'b0; |
| 92 | + b_service_in <= 1'b0; |
| 93 | + b_data_in <= 1'b0; |
| 94 | + b_disconnect_in <= 1'b0; |
| 95 | + b_metering_in <= 1'b0; |
| 96 | + |
| 97 | + // L to R: |
| 98 | + // - Bus Out P |
| 99 | + // - Bus In P |
| 100 | + // - Bus Out 0 |
| 101 | + // - Bus In 0 |
| 102 | + // - Bus Out 1 |
| 103 | + // - Bus In 1 |
| 104 | + // - Bus Out 2 |
| 105 | + // - Bus In 2 |
| 106 | + // - Bus Out 3 |
| 107 | + // - Bus In 3 |
| 108 | + // - Bus Out 4 |
| 109 | + // - Bus In 4 |
| 110 | + // - Bus Out 5 |
| 111 | + // - Bus In 5 |
| 112 | + // - Bus Out 6 |
| 113 | + // - Bus In 6 |
| 114 | + // - Bus Out 7 |
| 115 | + // - Bus In 7 |
| 116 | + // - Mark 0 Out |
| 117 | + // - Mark 0 In |
| 118 | + // |
| 119 | + // - Operational In |
| 120 | + // - Clock Out |
| 121 | + // - Status In |
| 122 | + // - Metering Out |
| 123 | + // - Address In |
| 124 | + // - Metering In |
| 125 | + // - Service In |
| 126 | + // - Request In |
| 127 | + // - Select In |
| 128 | + // - Data In |
| 129 | + // - Select Out |
| 130 | + // - X |
| 131 | + // - Address Out |
| 132 | + // - Data Out |
| 133 | + // - Command Out |
| 134 | + // - Disconnect In |
| 135 | + // - Suppress Out |
| 136 | + // - Hold Out |
| 137 | + // - Service Out |
| 138 | + // - Operational Out |
| 139 | + |
| 140 | + a_bus_out_parity <= driver[19]; |
| 141 | + a_bus_out <= driver[18:11]; |
| 142 | + a_mark_0_out <= driver[10]; |
| 143 | + a_clock_out <= driver[9]; // -> Operational In |
| 144 | + a_metering_out <= driver[8]; // -> Status In |
| 145 | + a_data_out <= driver[5]; // -> Service In |
| 146 | + a_suppress_out <= driver[3]; // -> Disconnect In |
| 147 | + a_service_out <= driver[1]; // -> Data In |
| 148 | + a_command_out <= driver[4]; // -> Request In |
| 149 | + a_address_out <= driver[6]; // -> Metering In |
| 150 | + a_select_out <= driver[7]; // -> Address In |
| 151 | + a_hold_out <= driver[2]; // -> Select In |
| 152 | + a_operational_out <= driver[0]; |
| 153 | + |
| 154 | + receiver <= { |
| 155 | + a_bus_in_parity, |
| 156 | + a_bus_in, |
| 157 | + a_mark_0_in, |
| 158 | + a_operational_in, |
| 159 | + a_status_in, |
| 160 | + a_address_in, |
| 161 | + a_metering_in, |
| 162 | + a_service_in, |
| 163 | + a_request_in, |
| 164 | + a_disconnect_in, |
| 165 | + a_select_in, |
| 166 | + a_data_in, |
| 167 | + 1'b0 |
| 168 | + }; |
| 169 | + end |
| 170 | + else |
| 171 | + begin |
| 172 | + b_bus_in <= a_bus_in; |
| 173 | + b_bus_in_parity <= a_bus_in_parity; |
| 174 | + b_mark_0_in <= a_mark_0_in; |
| 175 | + b_request_in <= a_request_in; |
| 176 | + b_select_in <= a_select_in; |
| 177 | + b_operational_in <= a_operational_in; |
| 178 | + b_address_in <= a_address_in; |
| 179 | + b_status_in <= a_status_in; |
| 180 | + b_service_in <= a_service_in; |
| 181 | + b_data_in <= a_data_in; |
| 182 | + b_disconnect_in <= a_disconnect_in; |
| 183 | + b_metering_in <= a_metering_in; |
| 184 | + |
| 185 | + a_bus_out <= b_bus_out; |
| 186 | + a_bus_out_parity <= b_bus_out_parity; |
| 187 | + a_mark_0_out <= b_mark_0_out; |
| 188 | + a_operational_out <= b_operational_out; |
| 189 | + a_hold_out <= b_hold_out; |
| 190 | + a_select_out <= b_select_out; |
| 191 | + a_address_out <= b_address_out; |
| 192 | + a_command_out <= b_command_out; |
| 193 | + a_service_out <= b_service_out; |
| 194 | + a_suppress_out <= b_suppress_out; |
| 195 | + a_data_out <= b_data_out; |
| 196 | + a_metering_out <= b_metering_out; |
| 197 | + a_clock_out <= b_clock_out; |
| 198 | + end |
| 199 | + end |
| 200 | +endmodule |
0 commit comments