Open badeaa3 opened 4 months ago
Adam, Cristian, and I spoke for a long time about the memory map. I believe we now understand it. Testing it now on the peary device and with spacely.
in a txt file file we put the following:
*BASE 0x0400000000
sw_write32_0,0x0,0xFFFFFFFF,True,True
sw_read32_0,0x4,0xFFFFFFFF,True,False
sw_read32_1,0x8,0xFFFFFFFF,True,False
The BASE address we set via vivado "Address Editor".
The syntax is then: name, offset, mask, read, write.
Then we generate the memory map using spacely.
source ~/.bashrc
conda activate spacelyvenv
cd /asic/projects/C/CMS_PIX_28/testing/spacely/PySpacely
python Spacely.py
# click enter
gen_mem_map()
select the txt file from the browser that opens. Then spacely returns the memory map:
> gen_mem_map()
<DBG> <2024-06-18 17:38:32> Executing "gen_mem_map()" as code
#define FPGA_REGS \
{ \
{"sw_write32_0", {FPGA_MEM, register_t<size_t>(0x000000, 0xffffffff, true, true, false)}}, \
{"sw_read32_0", {FPGA_MEM, register_t<size_t>(0x000000, 0xffffffff, true, true, false)}}, \
{"sw_read32_1", {FPGA_MEM, register_t<size_t>(0x000020, 0xffffffff, true, true, false)}}, \
}
We then copy-pasted those lines into the peary device memory map section here, scp'd the device to the ZCU petalinux, and recompiled peary.
Success!! We have successfully read from and written to a register in firmware via software: spacely (python) <-> peary <-> axi interface <-> firmware
Next step is to try to write to this register sw_write32_0
an actual configuration code (32 bit word). This should put the firmware in a state to generate the blck and blck_ana at 40 mhz offset by 5ns. The code is 4'h2, 4'h2, 11'h0, 1'h0, 1'h0, 5'h4, 6'hA
The first two entries 4'h2 4'h2 are the firmware ID.
With help of Giuseppe. Converting the code to int.
{4'h2, 4'h2, 11'h0, 1'h0, 1'h0, 5'h4, 6'hA}
00100010000000000000000100001010
570425610
Then I wrote it with spacely and this should trigger the firmware to produce the 40 MHz blck and blck_ana. And it did! The waveforms are not pretty yet (they can be cleaned up) ... but you see the two 40 MHz clocks that are separated by 10ns offset (because of what we set in the firmware).
We are now going to try to set different periods, delay, sign for the clocks within the firmware.
There are a set of tests written by Cristian here /asic/projects/C/CMS_PIX_28/abadea/spacely-caribou-common-blocks/cms_pix_28_test_firmware/vrf/fw_ipx_wrap_tb.sv
Wrote a short script to convert the hex list into an int that we can write with spacely. Used this to change the 40 MHz clock to a 10 MHz one by setting the clk_divide from 6'hA =10 to 6'h28 =40. Changes pushed to GitHub in the spacely routine https://github.com/Fermilab-Microelectronics/spacely-asic-config/blob/badea_041224/SMARTPIX28/SMARTPIX28_Routines.py#L102-L119
clk_divide = "6'h28" # divide the overall 400 MHz clock by 40 instead of 10 from "6'hA"
hex_list = ["4'h2", "4'h2", "11'h0", "1'h0", "1'h0", "5'h4", clk_divide]
temp = gen_sw_write32_0(hex_list) # custom program by us
sw_write32_0 = sg.INSTR["car"].set_memory("sw_write32_0", temp)
To-do's next:
Goal for the day: