Skip to content

Commit

Permalink
py test fix & whitespace cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
victorbesy committed Dec 25, 2023
1 parent adc43bd commit 303c990
Show file tree
Hide file tree
Showing 19 changed files with 483 additions and 528 deletions.
2 changes: 1 addition & 1 deletion examples/c/client_server/initiator/src/csC_Initiator.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ int main(void) {
msg = "initiator: data_act";
printf("\n%s String_act=%s",msg,String_act);
}

puts("\n\ncsC_Initiator end");
}

Expand Down
6 changes: 2 additions & 4 deletions examples/c/client_server/target/src/csC_Target.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@ int main(void) {
char *hostname;
int port;
int success=1;

//SVCV_INSTR_HASH_INDEX_DEFINE;

port = 0;//MY_PORT;
hostname = MY_HOST;
//
socket= shunt_cs_init_target(port,hostname);




if (socket<0) {
printf("\ncsC_Target::FATAL ERROR");
success=0;
Expand Down
2 changes: 1 addition & 1 deletion examples/c/user_api/target/src/apiC_Target.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ int main(void) {
//send loopback
success=shunt_pkt_send_longV (socket, &h_trnx, LongV);
if (success == 0 ) printf("\n target String data fail to send");

puts("\napiC_Target end");
}

Expand Down
Empty file.
48 changes: 24 additions & 24 deletions examples/py/sv2py/target/src/Target.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from shunt import *

class Target:

def __init__(self):
self.lib= Shunt()
self.String = ""
Expand All @@ -34,36 +34,36 @@ def init_target(self, portno, hostname):
socket_id = 0
socket_id = self.lib.shunt_py_target_init(portno, hostname)
return socket_id

def header_loopback_test(self,socket_id):

h_trnx = cs_header()
# Receive
Test_name = "\n SV2PY header_loopback_test recv"
result,h_trnx = self.lib.shunt_py_recv_header(socket_id)
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

## Send
Test_name = "\n SV2PY header_loopback_test send"
result = self.lib.shunt_py_send_header(socket_id, h_trnx)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def short_loopback_test(self, socket_id):
Short = 0xDEAD
Test_name = "\n SV2PY short_loopback_test recv"

# recv
result,Short = self.lib.shunt_py_recv_short(socket_id)
if result<=0 :
if result<=0 :
print(f"{Test_name} TARGET: TEST FAIL")
print(f"{Test_name} Short={hex(Short)}")

# send
Test_name = "\n SV2PY short_loopback_test send"
result= self.lib.shunt_py_send_short(socket_id, Short)
if result<=0 :
if result<=0 :
print(f"{Test_name} TARGET: TEST FAIL")

def int_loopback_test(self, socket_id):
Expand Down Expand Up @@ -95,7 +95,7 @@ def long_loopback_test(self, socket_id):
# send
Test_name = "\n SV2PY long_loopback_test send"
result = self.lib.shunt_py_send_long(socket_id, Long)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def byte_loopback_test(self, socket_id):
Expand All @@ -111,7 +111,7 @@ def byte_loopback_test(self, socket_id):
# send
Test_name = "\n SV2PY byte_loopback_test send"
result = self.lib.shunt_py_send_byte(socket_id, Byte)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def integer_loopback_test(self, socket_id):
Expand All @@ -127,7 +127,7 @@ def integer_loopback_test(self, socket_id):
# send
Test_name = "\n SV2PY integer_loopback_test send"
result = self.lib.shunt_py_send_integer(socket_id, Integer)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def time_loopback_test(self, socket_id):
Expand All @@ -143,7 +143,7 @@ def time_loopback_test(self, socket_id):
# send
Test_name = "\n SV2PY time_loopback_test send"
result = self.lib.shunt_py_send_time(socket_id, Time)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def bit_loopback_test(self, socket_id):
Expand All @@ -159,7 +159,7 @@ def bit_loopback_test(self, socket_id):
# send
Test_name = "\n SV2PY bit_loopback_test send"
result = self.lib.shunt_py_send_bit(socket_id, Bit)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def reg_loopback_test(self, socket_id):
Expand All @@ -175,7 +175,7 @@ def reg_loopback_test(self, socket_id):
# send
Test_name = "\n SV2PY reg_loopback_test send"
result = self.lib.shunt_py_send_reg(socket_id, Reg)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def logic_loopback_test(self, socket_id):
Expand All @@ -191,7 +191,7 @@ def logic_loopback_test(self, socket_id):
# send
Test_name = "\n SV2PY logic_loopback_test send"
result = self.lib.shunt_py_send_logic(socket_id, Logic)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def real_loopback_test(self, socket_id):
Expand All @@ -210,9 +210,9 @@ def real_loopback_test(self, socket_id):
result = self.lib.shunt_py_send_real(socket_id, Real)
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def string_loopback_test(self, socket_id):

Test_name = "\n SV2PY string_loopback_test recv"
String = "0000000000000000000000000000000000000000000000000000000"
result, received_string = self.lib.shunt_py_recv_string(socket_id,len(String))
Expand All @@ -226,28 +226,28 @@ def string_loopback_test(self, socket_id):
result = self.lib.shunt_py_send_string(socket_id, received_string)
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def bitN_loopback_test(self, socket_id):
BitN = [0] * 1025
Test_name = "\n SV2PY bitN_loopback_test recv"

# recv
h_trnx = cs_header()
result,h_trnx = self.lib.shunt_py_recv_header(socket_id)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")
result,BitN = self.lib.shunt_py_recv_bitN(socket_id,h_trnx.n_payloads)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")
print(f"\n{Test_name} BitN={BitN}")

# send
Test_name = "\n SV2PY bitN_loopback_test send"
result = self.lib.shunt_py_send_header(socket_id, h_trnx)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")
result = self.lib.shunt_py_send_bitN(socket_id, h_trnx, BitN)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def regN_loopback_test(self, socket_id):
Expand Down Expand Up @@ -315,7 +315,7 @@ def data_header_loopback_test(self, socket_id):
# send
Test_name = "\n SV2PY data_header_loopback_test send"
result = self.lib.shunt_py_send_data_header(socket_id, self.h_data)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def data_loopback_test(self, socket_id):
Expand All @@ -331,7 +331,7 @@ def data_loopback_test(self, socket_id):
# send
Test_name = "\n SV2PY data_loopback_test send"
result = self.lib.shunt_py_hs_send_data(socket_id, Data)
if result <= 0:
if result <= 0:
print(f"{Test_name} TARGET: TEST FAIL")

def header_data_loopback_test(self, socket_id):
Expand Down
4 changes: 2 additions & 2 deletions examples/sc/LT_simple_cs/initiator/src/initiator.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ struct Initiator: sc_module
trans->set_response_status( tlm::TLM_INCOMPLETE_RESPONSE ); // Mandatory initial value

shunt_long_t tlm_extension_id =0;

//socket->b_transport( *trans, delay ); // Blocking transport call

shunt_send_b_transport(m_socket,*trans,tlm_extension_id,delay );
shunt_recv_b_transport(m_socket,*trans,tlm_extension_id, delay );
cout << "SERVER trans = { " << (cmd ? 'W' : 'R') << ", " << hex << i
Expand Down
10 changes: 5 additions & 5 deletions examples/sc/LT_simple_sv/initiator/src/initiator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct Initiator: sc_module
// TLM-2 generic payload transaction, reused across calls to b_transport
m_socket = shunt_tlm_init_server(MY_PORT);
tlm::tlm_generic_payload* trans = new tlm::tlm_generic_payload;

cout<<"\nSERVER: shunt_cs_get_cs_header_leader()="<<hex <<shunt_cs_get_cs_header_leader()
<<" \nshunt_cs_get_tlm_data_leader()="<<hex <<shunt_cs_get_tlm_data_leader()
<<" \nshunt_cs_get_tlm_axi3_ext_leader()="<<hex<<shunt_cs_get_tlm_axi3_ext_leader()
Expand All @@ -55,7 +55,7 @@ struct Initiator: sc_module
// Generate a random sequence of reads and writes
for (int i = 32; i < 96; i += 4)
{


tlm::tlm_command cmd = static_cast<tlm::tlm_command>(rand() % 2);
if (cmd == tlm::TLM_WRITE_COMMAND) data = 0xFF000000 | i;
Expand Down Expand Up @@ -83,12 +83,12 @@ struct Initiator: sc_module
//
//socket->b_transport( *trans, delay ); // Blocking transport call
shunt_send_b_transport(m_socket,*trans,tlm_extension_id, delay );

shunt_cs_tlm_send_axi3_header(m_socket,&gp_ext);
shunt_cs_tlm_recv_axi3_header(m_socket,&gp_ext);

shunt_tlm_print_axi3_header(gp_ext,"SERVER: ");

shunt_recv_b_transport(m_socket,*trans, tlm_extension_id,delay );
cout << "SERVER trans recv = { " << (cmd ? 'W' : 'R') << ", " << hex << i
<< " } , data = " << hex << data << " at time " << sc_time_stamp()
Expand Down
24 changes: 6 additions & 18 deletions examples/sc/LT_simple_sv/target/src/Target.sv
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,16 @@ module automatic Target(input reg clk_i);
//MEM
//logic [31:0] mem [0:255]=0;
logic [31:0] mem_data;

logic [31:0] mem_byte_enable;

logic [31:0] mem_addr;

logic mem_we;

//logic mem_oe;
logic [31:0] mem_q;


bit end_sim ;

bit start_sim;

bit trnx_in_progress;

int clk_next;

int sockid ;



cs_tlm_generic_payload_header_t h;
cs_tlm_axi3_extension_payload_header_t h_ext;
cs_tlm_axi3_extension_payload_header_t h_ext_out;
Expand All @@ -63,19 +51,19 @@ module automatic Target(input reg clk_i);
mem_byte_enable=0;
mem_addr=0;
mem_we=0;

mem_q=0;

end_sim =0;
start_sim=0;
trnx_in_progress=0;
sockid =0;

$display("TARGET: shunt_dpi_tlm_header_id()=%h",shunt_dpi_tlm_header_id());
$display("TARGET: shunt_dpi_tlm_data_id()=%h", shunt_dpi_tlm_data_id());
$display("TARGET: shunt_dpi_tlm_axi3_ext_id()=%h",shunt_dpi_tlm_axi3_ext_id());
$display("TARGET: shunt_dpi_tlm_signal_id()=%h",shunt_dpi_tlm_signal_id());

sockid = shunt_dpi_target_init(`MY_PORT,`MY_HOST);
shunt_dpi_tlm_send_command(sockid,SHUNT_TLM_START_SIM);
start_sim =1;
Expand Down Expand Up @@ -116,7 +104,7 @@ module automatic Target(input reg clk_i);
if(h.command != SHUNT_TLM_END_SIM) begin
shunt_dpi_tlm_recv_axi3_header(sockid,h_ext);
shunt_dpi_tlm_axi3_header_print (h_ext,"TRAGET: ");
shunt_dpi_tlm_send_axi3_header (sockid,h_ext_out);
shunt_dpi_tlm_send_axi3_header (sockid,h_ext_out);
end
/* verilator lint_off BLKSEQ */
h.response_status = SHUNT_TLM_OK_RESPONSE;
Expand Down
2 changes: 1 addition & 1 deletion examples/sc/LT_simple_trns/initiator/src/target.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct Memory: sc_module
// Obliged to set response status to indicate successful completion
//trans.set_response_status( tlm::TLM_OK_RESPONSE );
shunt_long_t tlm_extension_id=0;

shunt_send_b_transport(m_socket,trans,tlm_extension_id,delay );
shunt_recv_b_transport(m_socket,trans,tlm_extension_id, delay );
}
Expand Down
2 changes: 1 addition & 1 deletion examples/sv/sv2c/initiator/src/Initiator.sv
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ module automatic Initiator;
return success;
/* verilator lint_on WIDTH */
endfunction : pkt_longV_loopback_test


function int header_loopback_test(int socket_id,int n_payloads=1);
string s_me = "header_loopback_test()";
Expand Down
Loading

0 comments on commit 303c990

Please sign in to comment.