raster work

This commit is contained in:
Peter McGoron 2022-12-17 00:46:04 +00:00
parent ffdf4fb2f2
commit 644f4142a2
9 changed files with 388 additions and 4072 deletions

View File

@ -1,202 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,13 @@
# Makefile for tests and hardware verification.
.PHONY: test clean
RAM_FIFO_SRC= ram_fifo.v ram_fifo_sim.cpp FIFO36E1.v
obj_dir/Vram_fifo.mk:
verilator --cc --exe -Wall --trace --trace-fst \
${RAM_FIFO_SRC}
obj_dir/Vram_fifo: obj_dir/Vram_fifo.mk
cd obj_dir && make -f Vram_fifo.mk
test: obj_dir/Vram_fifo
./obj_dir/Vram_fifo

View File

@ -0,0 +1,52 @@
/* YOSYS has a difficult time infering single port BRAM. It can infer
* double-port block ram, however. This module is written as a double
* port block ram, even though both clocks will end up being the same.
* TODO:
* "empty" and "full" status indiciators for simulation
* https://stackoverflow.com/questions/62703942/trouble-getting-yosys-to-infer-block-ram-array-rather-than-using-logic-cells-v
* The answer by "TinLethax" infers a BRAM.
*/
module ram_fifo #(
parameter DAT_WID = 24,
parameter FIFO_DEPTH = 1500,
parameter FIFO_DEPTH_WID = 11
) (
input RCLK,
input WCLK,
input rst,
input read_enable,
input write_enable,
input signed [DAT_WID-1:0] write_dat,
output reg signed [DAT_WID-1:0] read_dat
);
reg [DAT_WID-1:0] memory [FIFO_DEPTH-1:0];
initial memory[0] <= 24'b0;
/* Read domain */
reg [FIFO_DEPTH_WID-1:0] read_ptr = 0;
always @ (posedge RCLK) begin
if (rst) begin
read_ptr <= 0;
end else if (read_enable) begin
read_dat <= memory[read_ptr];
read_ptr <= read_ptr + 1;
end
end
/* Write domain */
reg [FIFO_DEPTH_WID-1:0] write_ptr = 0;
always @ (posedge WCLK) begin
if (rst) begin
write_ptr <= 0;
if (write_enable) begin
memory[write_ptr] <= write_dat;
wite_dat <= writr_dat + 1;
end
end
endmodule

View File

@ -0,0 +1,91 @@
#include <memory>
#include <limits>
#include <cstdint>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <random>
#include <unistd.h>
#include <verilated.h>
#include "Vraster_sim.h"
using ModType = Vram_fifo;
ModType *mod;
uint32_t main_time = 0;
static void run_clock() {
for (int i = 0; i < 2; i++) {
mod->clk = !mod->clk;
mod->eval();
main_time++;
}
}
static void cleanup_exit() {
mod->final();
delete mod;
}
static void init(int argc, char **argv) {
Verilated::commandArgs(argc, argv);
Verilated::traceEverOn(true);
mod = new ModType;
mod->clk = 0;
atexit(cleanup_exit);
}
static void push(uint32_t v) {
if (mod->full) {
fprintf(stderr, "Fifo full at push %d\n", i);
exit(1);
}
mod->in_dat = v;
mod->write_enable = 1;
while (!mod->write_fin)
run_clock();
mod->write_enable = 0;
run_clock();
}
static void pop(int i) {
if (mod->empty) {
fprintf(stderr, "Fifo empty at pop %d\n", i);
exit(1);
}
mod->read_enable = 1;
while (!mod->read_fin)
run_clock();
mod->read_enable = 0;
run_clock();
}
#define MAX_VALS 32000/24
uint32_t vals[MAX_VALS];
int main(int argc, char **argv) {
init(argc, argv);
init_values();
mod->rst = 0;
mod->read_enable = 0;
mod->write_enable = 0;
mod->in_dat = 0;
run_clock();
/* Simple test */
for (int i = 0; i < MAX_VALS; i++) {
vals[i] = rand() & 0xFFFFFFFFFFFF;
push(vals[i], i);
}
for (int i = 0; i < MAX_VALS; i++) {
pop(i);
if (mod->out_dat != vals[i]) {
fprintf(stderr, "expect %u, %u\n", vals[i], mod->out_dat);
return 1;
}
}
return 0;
}

View File

@ -1,7 +1,16 @@
/* Ram shim. This is an interface designed for a LiteX RAM /* Ram shim. This is an interface designed for a LiteX RAM
* DMA module. It can also be connected to a simulator. * DMA module. It can also be connected to a simulator.
* *
* The read end is implemented in C since all of this is
* backed by memory.
*
* THIS MODULE ASSUMES that RAM_WORD < DAT_WID < RAM_WORD*2. * THIS MODULE ASSUMES that RAM_WORD < DAT_WID < RAM_WORD*2.
*
* TODO: Buffer the data (using something like block ram) and
* write it out asynchronously. This will require instantiating
* the block ram primitive directly for Yosys. This should make
* writes to RAM smoother, and reads smoother when the CPU is
* reading the data.
*/ */
module ram_shim #( module ram_shim #(
parameter BASE_ADDR = 32'h1000000, parameter BASE_ADDR = 32'h1000000,
@ -15,6 +24,15 @@ module ram_shim #(
input commit, input commit,
output reg finished, output reg finished,
/* Used by the kernel code to request the current
* location of the FIFO head. Used to memcpy data,
* it might better than repeatedly calling a FIFO
* read.
*/
input read_end_req_off,
output reg [RAM_WID-1:0] read_end_addr,
output reg read_end_req_valid,
output reg [RAM_WORD-1:0] word, output reg [RAM_WORD-1:0] word,
output [RAM_WID-1:0] addr, output [RAM_WID-1:0] addr,
output reg write, output reg write,
@ -29,6 +47,16 @@ reg [2:0] state = WAIT_ON_COMMIT;
reg [MAX_BYTE_WID-1:0] offset = 0; reg [MAX_BYTE_WID-1:0] offset = 0;
assign addr = BASE_ADDR + {{(RAM_WID - MAX_BYTE_WID){1'b0}}, offset}; assign addr = BASE_ADDR + {{(RAM_WID - MAX_BYTE_WID){1'b0}}, offset};
initial read_end_req_valid = 0;
always @ (posedge clk) begin
if (read_end_req_off && !read_end_req_valid) begin
read_end_req_valid = 1;
read_end_addr <= addr;
end else if (read_end_req_valid && !read_end_req_off) begin
read_end_req_valid <= 0;
end
end
always @ (posedge clk) begin always @ (posedge clk) begin
case (state) case (state)

View File

@ -13,8 +13,6 @@ module raster #(
output reg finished, output reg finished,
output reg running, output reg running,
/* Amount of steps per sample. */
input [STEPWID-1:0] steps_per_sample_in,
/* Amount of samples in one line (forward) */ /* Amount of samples in one line (forward) */
input [SAMPLEWID-1:0] max_samples_in, input [SAMPLEWID-1:0] max_samples_in,
/* Amount of lines in the output. */ /* Amount of lines in the output. */
@ -27,10 +25,6 @@ module raster #(
input signed [DAC_DATA_WID-1:0] dx_in, input signed [DAC_DATA_WID-1:0] dx_in,
input signed [DAC_DATA_WID-1:0] dy_in, input signed [DAC_DATA_WID-1:0] dy_in,
/* Vertical steps to go to the next line. */
input signed [DAC_DATA_WID-1:0] dx_vert_in,
input signed [DAC_DATA_WID-1:0] dy_vert_in,
/* X and Y DAC piezos */ /* X and Y DAC piezos */
output x_arm, output x_arm,
output [DAC_WID-1:0] x_to_dac, output [DAC_WID-1:0] x_to_dac,
@ -124,8 +118,8 @@ reg [STATE_WID-1:0] state = WAIT_ON_ARM;
reg [SAMPLEWID-1:0] sample = 0; reg [SAMPLEWID-1:0] sample = 0;
reg [SAMPLEWID-1:0] line = 0; reg [SAMPLEWID-1:0] line = 0;
reg [TIMER_WID-1:0] counter = 0; reg [TIMER_WID-1:0] counter = 0;
reg [DAC_DATA_WID-1:0] x_val = 0; reg signed [DAC_DATA_WID-1:0] x_val = 0;
reg [DAC_DATA_WID-1:0] y_val = 0; reg signed [DAC_DATA_WID-1:0] y_val = 0;
/* Buffer to store all measured ADC values. This /* Buffer to store all measured ADC values. This
* is shifted until it is all zeros to determine * is shifted until it is all zeros to determine
@ -143,8 +137,6 @@ reg [ADCNUM-1:0] adc_used = 0;
reg is_reverse = 0; reg is_reverse = 0;
reg signed [DAC_DATA_WID-1:0] dx = 0; reg signed [DAC_DATA_WID-1:0] dx = 0;
reg signed [DAC_DATA_WID-1:0] dy = 0; reg signed [DAC_DATA_WID-1:0] dy = 0;
reg signed [DAC_DATA_WID-1:0] dx_vert = 0;
reg signed [DAC_DATA_WID-1:0] dy_vert = 0;
reg [TIMER_WID-1:0] settle_time = 0; reg [TIMER_WID-1:0] settle_time = 0;
reg [SAMPLEWID-1:0] max_samples = 0; reg [SAMPLEWID-1:0] max_samples = 0;
@ -171,11 +163,8 @@ always @ (posedge clk) begin
adc_used <= adc_used_in; adc_used <= adc_used_in;
dx <= dx_in; dx <= dx_in;
dy <= dy_in; dy <= dy_in;
dx_vert <= dx_vert_in;
dy_vert <= dy_vert_in;
max_samples <= max_samples_in; max_samples <= max_samples_in;
max_lines <= max_lines_in; max_lines <= max_lines_in;
steps_per_sample <= steps_per_sample_in;
settle_time <= settle_time_in; settle_time <= settle_time_in;
is_reverse <= 0; is_reverse <= 0;
@ -289,10 +278,11 @@ always @ (posedge clk) begin
finished <= 1; finished <= 1;
running <= 0; running <= 0;
end else begin end else begin
x_val <= x_val + dx_vert; /* rotation of (dx,dy) by 90° -> (dy, -dx) */
x_val <= x_val + dy;
x_to_dac <= {4'b0001, x_val + dx_vert}; x_to_dac <= {4'b0001, x_val + dx_vert};
x_arm <= 1; x_arm <= 1;
y_val <= y_val + dy_vert; y_val <= y_val - dx;
y_to_dac <= {4'b0001, y_val + dy_vert}; y_to_dac <= {4'b0001, y_val + dy_vert};
y_arm <= 1; y_arm <= 1;
line <= line + 1; line <= line + 1;

View File

@ -0,0 +1,109 @@
#include <memory>
#include <limits>
#include <cstdint>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <random>
#include <unistd.h>
#include <verilated.h>
#include "Vraster_sim.h"
using ModType = Vraster_sim;
ModType *mod;
uint32_t main_time = 0;
static void run_clock() {
for (int i = 0; i < 2; i++) {
mod->clk = !mod->clk;
mod->eval();
main_time++;
}
}
static void cleanup_exit() {
mod->final();
delete mod;
}
static void init(int argc, char **argv) {
Verilated::commandArgs(argc, argv);
Verilated::traceEverOn(true);
mod = new ModType;
mod->clk = 0;
atexit(cleanup_exit);
}
static void init_values() {
mod->arm = 0;
mod->max_samples_in = 512;
mod->max_lines_in = 512;
/* Settle time is 1 μs */
mod->settle_time_in = 100;
mod->dx_in = 17;
mod->dy_in = 13;
mod->coord_dac[0] = 0;
mod->coord_dac[1] = 0;
for (int i = 0; i < ADCNUM; i++)
mod->adc_data[i] = 0;
mod->adc_finished = 0;
mod->adc_used_in = 0;
mod->ram_valid = 0;
}
uint32_t *measured_values[ADCNUM];
static void init_measurements() {
std::default_random_engine generator{};
std::normal_distribution<> dist{10000, 100};
std::random_device rd;
for (int i = 0; i < ADCNUM; i++) {
generator.seed(rd());
measured_values[i] = new int32_t[mod->max_lines_in][mod->max_samples_in];
for (int j = 0; j < mod->max_lines_in; j++) {
for (int k = 0; k < mod->max_samples_in; k++) {
measured_values[i][j][k] = dist(generator);
}
}
}
}
static void deinit_measurement() {
for (int i = 0; i < ADCNUM; i++) {
delete measured_values[i];
}
}
static std::array<uint16_t, 1 << MAX_BYTE_WID> fifo;
static uint32_t read_pos, write_pos;
static void handle_ram() {
}
static void handle_adc() {
static int cntr[ADCNUM] = {0};
static bool measuring[ADCNUM] = {0};
for (int i = 0; i < ADCNUM; i++) {
if (mod->adc_used_in & 1) {
}
int main(int argc, char **argv) {
init(argc, argv);
init_values();
init_measurements();
run_clock();
mod->arm = 1;
while (!mod->finished) {
run_clock();
handle_ram();
}
return 0;
}

View File

@ -1,3 +1,4 @@
`timescale 10ns/10ns
module raster_sim #( module raster_sim #(
parameter SAMPLEWID = 9, parameter SAMPLEWID = 9,
parameter DAC_DATA_WID = 20, parameter DAC_DATA_WID = 20,
@ -12,15 +13,16 @@ module raster_sim #(
parameter MAX_BYTE_WID = 13, parameter MAX_BYTE_WID = 13,
parameter DAT_WID = 24, parameter DAT_WID = 24,
parameter RAM_WORD = 16, parameter RAM_WORD = 16,
parameter RAM_WID = 32 parameter RAM_WID = 32,
parameter RAM_SIM_WAIT_TIME = 54,
parameter ADC_SIM_WAIT_TIME = 54
) ( ) (
input clk, input clk,
input arm, input arm,
output reg finished, output reg finished,
output reg running, output reg running,
/* Amount of steps per sample. */
input [STEPWID-1:0] steps_per_sample_in,
/* Amount of samples in one line (forward) */ /* Amount of samples in one line (forward) */
input [SAMPLEWID-1:0] max_samples_in, input [SAMPLEWID-1:0] max_samples_in,
/* Amount of lines in the output. */ /* Amount of lines in the output. */
@ -37,18 +39,7 @@ module raster_sim #(
input signed [DAC_DATA_WID-1:0] dx_vert_in, input signed [DAC_DATA_WID-1:0] dx_vert_in,
input signed [DAC_DATA_WID-1:0] dy_vert_in, input signed [DAC_DATA_WID-1:0] dy_vert_in,
/* X and Y DAC piezos */ output reg [DAC_DATA_WID-1:0] coord_dac [1:0],
output x_arm,
output [DAC_WID-1:0] x_to_dac,
/* verilator lint_off UNUSED */
input [DAC_WID-1:0] x_from_dac,
input x_finished,
output y_arm,
output [DAC_WID-1:0] y_to_dac,
/* verilator lint_off UNUSED */
input [DAC_WID-1:0] y_from_dac,
input y_finished,
/* Connections to all possible ADCs. These are connected to SPI masters /* Connections to all possible ADCs. These are connected to SPI masters
* and they will automatically extend ADC value lengths to their highest * and they will automatically extend ADC value lengths to their highest
@ -63,14 +54,95 @@ module raster_sim #(
/* DMA interface */ /* DMA interface */
output [RAM_WORD-1:0] word, output [RAM_WORD-1:0] word,
output [RAM_WID-1:0] addr, output [RAM_WID-1:0] addr,
output ram_write, output reg ram_write,
input ram_valid input ram_valid
); );
/**** DAC simulation ****/
reg [DAC_WID-1:0] coord_write_buf [1:0];
reg [DAC_WID-1:0] coord_to_dac [1:0];
reg [DAC_WID-1:0] coord_from_dac [1:0];
wire coord_arm [1:0];
reg coord_finished [1:0];
genvar ci;
generate for (ci = 0; ci < 2; ci = ci + 1) begin
initial begin
coord_write_buf[ci] = 0;
coord_to_dac[ci] = 0;
coord_from_dac[ci] = 0;
coord_finished[ci] = 0;
end
always @ (posedge clk) begin
if (coord_arm[ci] && !coord_finished[ci]) begin
coord_to_dac[ci] <= coord_write_buf[ci];
coord_finished[ci] <= 1;
case (coord_from_dac[ci][DAC_WID-1:DAC_WID-4])
4'b1001: begin
coord_write_buf[ci] <= {4'b1001, coord_dac[ci]};
end
4'b0001: begin
coord_write_buf[ci] <= 0;
coord_dac[ci] <= coord_from_dac[ci][DAC_WID-4-1:0];
end
endcase
end else if (!coord_arm[ci]) begin
coord_finished[ci] <= 0;
end
end
end endgenerate
/**** ADC Shim ****/
wire adc_arm_internal;
reg [31:0] adc_wait_cntr = 0;
always @ (posedge clk) begin
if (adc_arm_internal != 0) begin
if (adc_wait_cntr < ADC_SIM_WAIT_TIME) begin
adc_wait_cntr <= adc_wait_cntr + 1;
end else begin
adc_arm <= adc_arm_internal;
end
end else begin
adc_wait_cntr <= 0;
end
end
/**** RAM Shim ****/
/* Check all addresses are valid. */
property address_in_range;
@(posedge clk)
ram_commit |->
BASE_ADDR <= addr && addr < BASE_ADDR + (1 << MAX_BYTE_WID);
endproperty
address_in_range_assert: assert property (address_in_range);
wire signed [DAT_WID-1:0] ram_data; wire signed [DAT_WID-1:0] ram_data;
wire ram_commit; wire ram_commit;
wire ram_write_finished; wire ram_write_finished;
wire ram_write_internal = 0;
reg [31:0] ram_cntr = 0;
always @ (posedge clk) begin
if (ram_commit) begin
if (ram_cntr < RAM_SIM_WAIT_TIME) begin
ram_cntr <= ram_cntr + 1;
end else begin
ram_write <= 1;
end
end else begin
ram_cntr <= 0;
ram_write <= 0;
end
end
ram_shim #( ram_shim #(
.BASE_ADDR(BASE_ADDR), .BASE_ADDR(BASE_ADDR),
.MAX_BYTE_WID(MAX_BYTE_WID), .MAX_BYTE_WID(MAX_BYTE_WID),
@ -84,7 +156,7 @@ ram_shim #(
.finished(ram_write_finished), .finished(ram_write_finished),
.word(word), .word(word),
.addr(addr), .addr(addr),
.write(ram_write), .write(ram_write_internal),
.valid(ram_valid) .valid(ram_valid)
); );
@ -120,7 +192,7 @@ raster #(
.y_from_dac(y_from_dac), .y_from_dac(y_from_dac),
.y_finished(y_finished), .y_finished(y_finished),
.adc_arm(adc_arm), .adc_arm(adc_arm_internal),
.adc_data(adc_data), .adc_data(adc_data),
.adc_finished(adc_finished), .adc_finished(adc_finished),