-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue#5 - cocotb spec, dev and status #19
Comments
In addition to generating random data patterns, add an option for Incrementing Data Pattern. Such option would checking the downstream data integrity easier. It would also facilitate the process of following image transformations when looking at the waves. Also add a new task category: Generate Errors and Corner Cases. For the starters, within it, add options for inserting:
These options can be specified as the max deviation from the nominal, and the model would then randomly deviate within that range. Within Line and Frame Control Functions category, provide an option to specify Resolution and FPS. For the starters, this set needs to include at least the rates supported by our current RTL:
|
On current branch issue#5 we have implemented basic functions for control signals sequence = [
([0b00000000, 0b11111111], 40), # Some random data at the start
([0b10111000, 0b01000111], 20), # Sync bytes b8b8
([0b00010010, 0b11101101], 20) # Start of long packet
] After the simulation is done, we can obtain results and see that everything works fine, except for the part of the From folder |
First of all, the simulation is now working pretty much good. Everything was done using Verilator. Of course, there were many problems regarding the choice of the simulator, but from this point CSI model can be continued. So, as we can see from the image below, Current functions in python script are not so edited nor readable. However, the first task from this issue is done and tested successfully. Next tasks are related to the class and much prettier way of sending data. For curiosity, here are some lines of code that send sequence of data to the differential signal sequence = [
([0x00, 0xFF], 2), # Some random data at the start
([0xB8, 0x47], 1), # Sync bytes b8b8
([0x12, 0xFF], 1), # Start of frame (FF inv. -> 00)
([0x81, 0x7E], 3), # Random data
([0xFF, 0x00], 2), # Random data
([0x00, 0xFF], 2), # Random data
([0xB8, 0x47], 1), # Sync bytes b8b8
([0x32, 0xED], 1), # Start of long packet (32h bytes, ED inv. -> 12) - EMBEDDED DATA
([0x11, 0xFF], 1), # (FF inv. -> 00), combined with previous 32 --> 0032 bytes to read
([0xFF, 0x00], 32), # Data for read
([0x00, 0xFF], 2), # Random data
([0xB8, 0x47], 1), # Sync bytes b8b8
([0x32, 0xD7], 1), # Start of long packet (32h bytes, D7 inv. -> 28) - START OF LINE
([0x11, 0xFF], 1), # (FF inv. -> 00), combined with previous 32 --> 0032 bytes to read
([0x22, 0xDD], 32), # Data for read
] Definitely, this can be done more efficiently and that will be done in the next tasks. About your previous suggestions @chili-chips-ba:
|
I'll mention some of issues I encountered with the simulators. Icarus Issues: Additionally, when it comes to the Having tried to overcome these problems by adding `ifdef branches for Icarus where simpler, more primitive Verilog constructs were used, we have soon realized that such approach was not maintainable, not scalable and not worth further investments in our time and effort. Consequently, Icarus dev track was abandoned. Verilator Issues: We've also experienced problems in cocotb interaction with Verilator. A good example of that is signal[lane*2 + 1].value = bit_value # Positive bit
signal[lane*2].value = ~bit_value & 0x1 # Negative bit (inverse) Verilator, on the other hand, was stubbornly not cooperative on this front, not even when forces were used. Using trial-and-error iterative method, after some time we've managed to find a form that works, which is by assigning all bits in one-and-only-one co-routine, such as: bit_a = (byte0 >> bit) & 0x1
bit_b = ~bit_a & 0x1
bit_c = (byte1 >> bit) & 0x1
bit_d = ~bit_c & 0x1
# Set the signal values for both lanes
signal.value = (bit_b << 3) | (bit_a << 2) | (bit_d << 1) | bit_c Additionally, below is the image showing the specific error when the simple and straightforward Icarus form was used with Verilator. Having pulled quite a bit of hair, and thinking at first that some small, unimposing detail was overlooked, we then started looking around. It did not take long to uncover that these issues were also encountered by the others, who left a solid track record of similar problems: Verilator Pull Request #2728 |
ECC successfully tested Module def calculate_ecc(self, byte1, byte2, byte3):
"""
Calculate the ECC for the given three bytes.
The ECC is computed over the 24 bits formed by concatenating the three bytes.
"""
data = (byte1 << 16) | (byte2 << 8) | byte3
ecc = 0
ecc_bit5 = ((data >> 10) & 1) ^ ((data >> 11) & 1) ^ ((data >> 12) & 1) ^ ((data >> 13) & 1) ^ ((data >> 14) & 1) ^ ((data >> 15) & 1) ^ ((data >> 16) & 1) ^ ((data >> 17) & 1) ^ ((data >> 18) & 1) ^ ((data >> 19) & 1) ^ ((data >> 21) & 1) ^ ((data >> 22) & 1) ^ ((data >> 23) & 1)
ecc |= ecc_bit5 << 5
ecc_bit4 = ((data >> 4) & 1) ^ ((data >> 5) & 1) ^ ((data >> 6) & 1) ^ ((data >> 7) & 1) ^ ((data >> 8) & 1) ^ ((data >> 9) & 1) ^ ((data >> 16) & 1) ^ ((data >> 17) & 1) ^ ((data >> 18) & 1) ^ ((data >> 19) & 1) ^ ((data >> 20) & 1) ^ ((data >> 22) & 1) ^ ((data >> 23) & 1)
ecc |= ecc_bit4 << 4
ecc_bit3 = ((data >> 1) & 1) ^ ((data >> 2) & 1) ^ ((data >> 3) & 1) ^ ((data >> 7) & 1) ^ ((data >> 8) & 1) ^ ((data >> 9) & 1) ^ ((data >> 13) & 1) ^ ((data >> 14) & 1) ^ ((data >> 15) & 1) ^ ((data >> 19) & 1) ^ ((data >> 20) & 1) ^ ((data >> 21) & 1) ^ ((data >> 23) & 1)
ecc |= ecc_bit3 << 3
ecc_bit2 = ((data >> 0) & 1) ^ ((data >> 2) & 1) ^ ((data >> 3) & 1) ^ ((data >> 5) & 1) ^ ((data >> 6) & 1) ^ ((data >> 9) & 1) ^ ((data >> 11) & 1) ^ ((data >> 12) & 1) ^ ((data >> 15) & 1) ^ ((data >> 18) & 1) ^ ((data >> 20) & 1) ^ ((data >> 21) & 1) ^ ((data >> 22) & 1)
ecc |= ecc_bit2 << 2
ecc_bit1 = ((data >> 0) & 1) ^ ((data >> 1) & 1) ^ ((data >> 3) & 1) ^ ((data >> 4) & 1) ^ ((data >> 6) & 1) ^ ((data >> 8) & 1) ^ ((data >> 10) & 1) ^ ((data >> 12) & 1) ^ ((data >> 14) & 1) ^ ((data >> 17) & 1) ^ ((data >> 20) & 1) ^ ((data >> 21) & 1) ^ ((data >> 22) & 1) ^ ((data >> 23) & 1)
ecc |= ecc_bit1 << 1
ecc_bit0 = ((data >> 0) & 1) ^ ((data >> 1) & 1) ^ ((data >> 2) & 1) ^ ((data >> 4) & 1) ^ ((data >> 5) & 1) ^ ((data >> 7) & 1) ^ ((data >> 10) & 1) ^ ((data >> 11) & 1) ^ ((data >> 13) & 1) ^ ((data >> 16) & 1) ^ ((data >> 20) & 1) ^ ((data >> 21) & 1) ^ ((data >> 22) & 1) ^ ((data >> 23) & 1)
ecc |= ecc_bit0
return ecc |
@Juninho99 great work on creating:
The next step is to distill some of this info into a brief, yet informative README.md section on how to run the simulation and modify it to per-user needs, with a few examples, as you've shown above. Please, also bring up the issues you've found with Verilator, cocotb and Icarus to their relevant owners. |
Let's also make the tests auto-checking, so that the designer does not need to eye-ball the waveforms for every sim run, but instead the test itself finds and reports issues in RTL |
Yes, definitely we need to provide some tests that will be auto-checked. It will be much easier for users to see where the issue is. Also we will briefly explain everything according to our model and scripts, but first of all we want to make sure that all the tasks with this issue are done. |
Issue: Develop Testbench Environment for Testing CSI-2 Camera Model in Cocotb
Description
The goal of this issue is to develop a testbench environment for testing a CSI-2 camera model using Cocotb. The primary objective is to create a Python class that simulates the actual operation of a camera by generating and sending
cam_dphy_dat
andcam_dphy_clk
signals. These signals are differential inputs to the top module, and the class will be responsible for setting these signals to specific values.Tasks
1. Basic Signal Generation
cam_dphy_dat
andcam_dphy_clk
2. Camera Simulation Class
cam_dphy_dat
andcam_dphy_clk
.3. Data Transmission Functions
4. Line and Frame Control Functions
5. ECC Calculation
6. Generate Errors and Corner Cases
7. Verilator Adaptations
8. Integration and Testing
9. Documentation
Expected Outcome
By completing this issue, we expect to have a fully functional testbench environment capable of simulating the CSI-2 camera model's behavior. This environment will facilitate thorough testing and validation of the top module's interaction with the camera signals, ensuring robust and reliable operation.
The text was updated successfully, but these errors were encountered: