Skip to content

Commit

Permalink
4.1: minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
dcamarmas committed Sep 20, 2024
1 parent 8553e9f commit 873ad7d
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 12 deletions.
8 changes: 4 additions & 4 deletions architecture/MIPS_32.json
Original file line number Diff line number Diff line change
Expand Up @@ -4471,7 +4471,7 @@
"valueField": "010110"
}
],
"definition": "fd = 1.0/Math.sqrt(fs);"
"definition": "if (fs >= 0)\n { fd = 1.0/Math.sqrt(fs); }\n else { capi_raise('Square root of a negative number is not allowed.'); }"
},
{
"name": "rsqrt.s",
Expand Down Expand Up @@ -4519,7 +4519,7 @@
"valueField": "010110"
}
],
"definition": "fd = 1.0/Math.sqrt(fs);"
"definition": "if (fs >= 0)\n { fd = 1.0/Math.sqrt(fs); }\n else { capi_raise('Square root of a negative number is not allowed.'); }"
},
{
"name": "sb",
Expand Down Expand Up @@ -4908,7 +4908,7 @@
"valueField": "000100"
}
],
"definition": "fd = Math.sqrt(fs);"
"definition": "if (fs >= 0)\n { fd = Math.sqrt(fs); }\n else { capi_raise('Square root of a negative number is not allowed.'); }"
},
{
"name": "sqrt.s",
Expand Down Expand Up @@ -4956,7 +4956,7 @@
"valueField": "000100"
}
],
"definition": "fd = Math.sqrt(fs);"
"definition": "if (fs >= 0)\n { fd = Math.sqrt(fs); }\n else { capi_raise('Square root of a negative number is not allowed.'); }"
},
{
"name": "sra",
Expand Down
10 changes: 5 additions & 5 deletions architecture/RISC_V_RV32IMFD.json
Original file line number Diff line number Diff line change
Expand Up @@ -4369,15 +4369,15 @@
"name": "fsqrt.d",
"type": "Arithmetic floating point",
"signature_definition": "F0 F4 F3",
"signature": "FSQRT.D,DFP-Reg,DFP-Reg",
"signatureRaw": "FSQRT.D rd rs1",
"signature": "fsqrt.d,DFP-Reg,DFP-Reg",
"signatureRaw": "fsqrt.d rd rs1",
"co": "1010011",
"cop": "010110100000",
"nwords": 1,
"clk_cycles": 1,
"fields": [
{
"name": "FSQRT.D",
"name": "fsqrt.d",
"type": "co",
"startbit": 6,
"stopbit": 0
Expand Down Expand Up @@ -4409,7 +4409,7 @@
"stopbit": 7
}
],
"definition": "rd = Math.sqrt(rs1);",
"definition": "if (rs1 >= 0)\n { rd = Math.sqrt(rs1); }\n else { capi_raise('Square root of a negative number is not allowed.'); }",
"separated": [
false,
false,
Expand Down Expand Up @@ -4463,7 +4463,7 @@
"stopbit": 7
}
],
"definition": "rd = Math.sqrt(rs1);",
"definition": "if (rs1 >= 0)\n { rd = Math.sqrt(rs1); }\n else { capi_raise('Square root of a negative number is not allowed.'); }",
"separated": [
false,
false,
Expand Down
24 changes: 24 additions & 0 deletions js/creator_executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,30 @@ function execute_instruction ( )
}
}
else{

/////////
if ( signatureParts[i] == "offset_words" )
{
if(instructionExecParts[i].match(/^0x/))
{
var value = parseInt(instructionExecParts[i]);

var nbits = 4 * value.toString(16).length ; // nbits = nbits of 0xFFC = 8 bits
var value_bin = value.toString(2).padStart(nbits, '0') ; // value_bin = '111111111100'
if (value_bin[0] == '1') {
value_bin = ''.padStart(32 - nbits, '1') + value_bin ; // value_bin = '1111...111' + '111111111100' ; TODO: 32 -> nwords...
}
else {
value_bin = ''.padStart(32 - nbits, '0') + value_bin ; // value_bin = '0000...000' + '011111111100' ; TODO: 32 -> nwords...
}
value = parseInt(value_bin, 2) >> 0 ;
instructionExecParts[i] = value ; // -...

console_log(instructionExecParts[i]);
}
}
/////////

var_readings_definitions[signatureRawParts[i]] = "var " + signatureRawParts[i] + " = " + instructionExecParts[i] + ";\n";
}
}
Expand Down
24 changes: 24 additions & 0 deletions js/min.creator_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -7081,6 +7081,30 @@ function execute_instruction ( )
}
}
else{

/////////
if ( signatureParts[i] == "offset_words" )
{
if(instructionExecParts[i].match(/^0x/))
{
var value = parseInt(instructionExecParts[i]);

var nbits = 4 * value.toString(16).length ; // nbits = nbits of 0xFFC = 8 bits
var value_bin = value.toString(2).padStart(nbits, '0') ; // value_bin = '111111111100'
if (value_bin[0] == '1') {
value_bin = ''.padStart(32 - nbits, '1') + value_bin ; // value_bin = '1111...111' + '111111111100' ; TODO: 32 -> nwords...
}
else {
value_bin = ''.padStart(32 - nbits, '0') + value_bin ; // value_bin = '0000...000' + '011111111100' ; TODO: 32 -> nwords...
}
value = parseInt(value_bin, 2) >> 0 ;
instructionExecParts[i] = value ; // -...

console_log(instructionExecParts[i]);
}
}
/////////

var_readings_definitions[signatureRawParts[i]] = "var " + signatureRawParts[i] + " = " + instructionExecParts[i] + ";\n";
}
}
Expand Down
2 changes: 1 addition & 1 deletion js/min.creator_web.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion test/mips/instructions/test_mips_instruction_058.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

cr[PC]:0x8c; ir[1,at]:0x46100000; ir[2,v0]:0xa; sfpr[f0]:0x40700000; sfpr[f2]:0xC0AB3200; sfpr[f4]:0x40B56400; sfpr[f6]:0x46192400; sfpr[f7]:0xC6016400; sfpr[f8]:0x46100000; sfpr[f10]:0x40300000; sfpr[f12]:0xFFF80000; sfpr[f14]:0x40528000; sfpr[f16]:0x42C60000; sfpr[f17]:0xFFC00000; sfpr[f18]:0x42C00000; dfpr[FP0]:0x4070000000000000; dfpr[FP2]:0xC0AB320000000000; dfpr[FP4]:0x40B5640000000000; dfpr[FP6]:0x46192400C6016400; dfpr[FP8]:0x4610000000000000; dfpr[FP10]:0x4030000000000000; dfpr[FP12]:0xFFF8000000000000; dfpr[FP14]:0x4052800000000000; dfpr[FP16]:0x42C60000FFC00000; dfpr[FP18]:0x42C0000000000000; keyboard[0x0]:''; display[0x0]:'';
Square root of a negative number is not allowed.
Square root of a negative number is not allowed.
cr[PC]:0x8c; ir[1,at]:0x46100000; ir[2,v0]:0xa; sfpr[f0]:0x40700000; sfpr[f2]:0xC0AB3200; sfpr[f4]:0x40B56400; sfpr[f6]:0x46192400; sfpr[f7]:0xC6016400; sfpr[f8]:0x46100000; sfpr[f10]:0x40300000; sfpr[f14]:0x40528000; sfpr[f16]:0x42C60000; sfpr[f18]:0x42C00000; dfpr[FP0]:0x4070000000000000; dfpr[FP2]:0xC0AB320000000000; dfpr[FP4]:0x40B5640000000000; dfpr[FP6]:0x46192400C6016400; dfpr[FP8]:0x4610000000000000; dfpr[FP10]:0x4030000000000000; dfpr[FP14]:0x4052800000000000; dfpr[FP16]:0x42C6000000000000; dfpr[FP18]:0x42C0000000000000; keyboard[0x0]:''; display[0x0]:'';

4 changes: 3 additions & 1 deletion test/mips/instructions/test_mips_instruction_064.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@

cr[PC]:0x8c; ir[1,at]:0x46100000; ir[2,v0]:0xa; sfpr[f0]:0x40700000; sfpr[f2]:0xC0AB3200; sfpr[f4]:0x40B56400; sfpr[f6]:0x46192400; sfpr[f7]:0xC6016400; sfpr[f8]:0x46100000; sfpr[f10]:0x3FB00000; sfpr[f12]:0xFFF80000; sfpr[f14]:0x3F8BACF9; sfpr[f15]:0x14C1BAD0; sfpr[f16]:0x3C257EB5; sfpr[f17]:0xFFC00000; sfpr[f18]:0x3C2AAAAB; dfpr[FP0]:0x4070000000000000; dfpr[FP2]:0xC0AB320000000000; dfpr[FP4]:0x40B5640000000000; dfpr[FP6]:0x46192400C6016400; dfpr[FP8]:0x4610000000000000; dfpr[FP10]:0x3FB0000000000000; dfpr[FP12]:0xFFF8000000000000; dfpr[FP14]:0x3F8BACF914C1BAD0; dfpr[FP16]:0x3C257EB5FFC00000; dfpr[FP18]:0x3C2AAAAB00000000; keyboard[0x0]:''; display[0x0]:'';
Square root of a negative number is not allowed.
Square root of a negative number is not allowed.
cr[PC]:0x8c; ir[1,at]:0x46100000; ir[2,v0]:0xa; sfpr[f0]:0x40700000; sfpr[f2]:0xC0AB3200; sfpr[f4]:0x40B56400; sfpr[f6]:0x46192400; sfpr[f7]:0xC6016400; sfpr[f8]:0x46100000; sfpr[f10]:0x3FB00000; sfpr[f14]:0x3F8BACF9; sfpr[f15]:0x14C1BAD0; sfpr[f16]:0x3C257EB5; sfpr[f18]:0x3C2AAAAB; dfpr[FP0]:0x4070000000000000; dfpr[FP2]:0xC0AB320000000000; dfpr[FP4]:0x40B5640000000000; dfpr[FP6]:0x46192400C6016400; dfpr[FP8]:0x4610000000000000; dfpr[FP10]:0x3FB0000000000000; dfpr[FP14]:0x3F8BACF914C1BAD0; dfpr[FP16]:0x3C257EB500000000; dfpr[FP18]:0x3C2AAAAB00000000; keyboard[0x0]:''; display[0x0]:'';

0 comments on commit 873ad7d

Please sign in to comment.