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 24, 2024
1 parent 7709932 commit 33c88c1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
26 changes: 15 additions & 11 deletions js/creator_executor.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,11 @@ function execute_instruction ( )
else{
bin = instructionExec.substring(((instruction_nwords*31) - instruction_fields[f].startbit), ((instruction_nwords*32) - instruction_fields[f].stopbit))
}
value = get_number_binary (bin);

// value = get_number_binary(bin) ;
value = parseInt(bin, 2).toString(16) ;
value_len = Math.abs(instruction_fields[f].startbit - instruction_fields[f].stopbit) ;
value = '0x' + value.padStart(value_len/4, '0') ;
break;

default:
Expand Down Expand Up @@ -321,7 +324,7 @@ function execute_instruction ( )
var var_readings_definitions_name = {};
var var_writings_definitions = {};

//Generate all registers, values, etc. readings
// Generate all registers, values, etc. readings
for (var i = 1; i < signatureRawParts.length; i++)
{
if (signatureParts[i] == "INT-Reg" || signatureParts[i] == "SFP-Reg" || signatureParts[i] == "DFP-Reg" || signatureParts[i] == "Ctrl-Reg")
Expand Down Expand Up @@ -352,23 +355,24 @@ function execute_instruction ( )
}
else{

/////////
/////////TODO: inm-signed
if ( signatureParts[i] == "offset_words" )
{
if(instructionExecParts[i].match(/^0x/))
if (instructionExecParts[i].startsWith("0x"))
{
var value = parseInt(instructionExecParts[i]);
var value = parseInt(instructionExecParts[i]);
var nbits = 4 * (instructionExecParts[i].length - 2) ; // 0xFFC -> 12 bits
var value_bin = value.toString(2).padStart(nbits, '0') ; // value_bin = '111111111100'

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'
// TODO: replace 32 with bits in architecture...
if (value_bin[0] == '1') {
value_bin = ''.padStart(32 - nbits, '1') + value_bin ; // value_bin = '1111...111' + '111111111100' ; TODO: 32 -> nwords...
value_bin = ''.padStart(32 - nbits, '1') + value_bin ; // value_bin = '1111...111' + '111111111100' ;
}
else {
value_bin = ''.padStart(32 - nbits, '0') + value_bin ; // value_bin = '0000...000' + '011111111100' ; TODO: 32 -> nwords...
value_bin = ''.padStart(32 - nbits, '0') + value_bin ; // value_bin = '0000...000' + '011111111100' ;
}
value = parseInt(value_bin, 2) >> 0 ;
instructionExecParts[i] = value ; // -...
instructionExecParts[i] = value ;

console_log(instructionExecParts[i]);
}
Expand Down Expand Up @@ -989,4 +993,4 @@ function get_register_binary (type, bin)
function get_number_binary (bin)
{
return "0x" + bin2hex(bin);
}
}
25 changes: 15 additions & 10 deletions js/min.creator_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -6966,8 +6966,11 @@ function execute_instruction ( )
else{
bin = instructionExec.substring(((instruction_nwords*31) - instruction_fields[f].startbit), ((instruction_nwords*32) - instruction_fields[f].stopbit))
}
value = get_number_binary (bin);

// value = get_number_binary(bin) ;
value = parseInt(bin, 2).toString(16) ;
value_len = Math.abs(instruction_fields[f].startbit - instruction_fields[f].stopbit) ;
value = '0x' + value.padStart(value_len/4, '0') ;
break;

default:
Expand Down Expand Up @@ -7051,7 +7054,7 @@ function execute_instruction ( )
var var_readings_definitions_name = {};
var var_writings_definitions = {};

//Generate all registers, values, etc. readings
// Generate all registers, values, etc. readings
for (var i = 1; i < signatureRawParts.length; i++)
{
if (signatureParts[i] == "INT-Reg" || signatureParts[i] == "SFP-Reg" || signatureParts[i] == "DFP-Reg" || signatureParts[i] == "Ctrl-Reg")
Expand Down Expand Up @@ -7082,23 +7085,24 @@ function execute_instruction ( )
}
else{

/////////
/////////TODO: inm-signed
if ( signatureParts[i] == "offset_words" )
{
if(instructionExecParts[i].match(/^0x/))
if (instructionExecParts[i].startsWith("0x"))
{
var value = parseInt(instructionExecParts[i]);
var value = parseInt(instructionExecParts[i]);
var nbits = 4 * (instructionExecParts[i].length - 2) ; // 0xFFC -> 12 bits
var value_bin = value.toString(2).padStart(nbits, '0') ; // value_bin = '111111111100'

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'
// TODO: replace 32 with bits in architecture...
if (value_bin[0] == '1') {
value_bin = ''.padStart(32 - nbits, '1') + value_bin ; // value_bin = '1111...111' + '111111111100' ; TODO: 32 -> nwords...
value_bin = ''.padStart(32 - nbits, '1') + value_bin ; // value_bin = '1111...111' + '111111111100' ;
}
else {
value_bin = ''.padStart(32 - nbits, '0') + value_bin ; // value_bin = '0000...000' + '011111111100' ; TODO: 32 -> nwords...
value_bin = ''.padStart(32 - nbits, '0') + value_bin ; // value_bin = '0000...000' + '011111111100' ;
}
value = parseInt(value_bin, 2) >> 0 ;
instructionExecParts[i] = value ; // -...
instructionExecParts[i] = value ;

console_log(instructionExecParts[i]);
}
Expand Down Expand Up @@ -7720,6 +7724,7 @@ function get_number_binary (bin)
{
return "0x" + bin2hex(bin);
}

/*
* Copyright 2018-2024 Felix Garcia Carballeira, Diego Camarmas Alonso, Alejandro Calderon Mateos
*
Expand Down
2 changes: 1 addition & 1 deletion js/min.creator_web.js

Large diffs are not rendered by default.

0 comments on commit 33c88c1

Please sign in to comment.